const Router = require('koa-router')
const { verifyToken } = require('@/utils/jwt')
const errorQuestionValidate = require('@/middlewares/validateMiddlewares/errorQuestionValidate')
const {
  validateSlideCode
} = require('@/middlewares/validateMiddlewares/userValidate')
const errorQuestionController = require('@/controller/errorQuestionController')

const router = new Router()

/**
 * 获取错题列表
 */
router.get(
  '/list',
  verifyToken(),
  errorQuestionValidate.listErrorQuestionValidate,
  errorQuestionController.listErrorQuestion
)

/**
 * 获取错题试卷列表
 */
router.get(
  '/paperList',
  verifyToken(),
  errorQuestionValidate.listPaperValidate,
  errorQuestionController.listErrorPaper
)

/**
 * 创建错题列表
 */
router.post(
  '/create',
  verifyToken(),
  errorQuestionValidate.createErrorQuestionValidate,
  errorQuestionController.createErrorQuestion
)

/**
 * 删除错题列表
 */
router.delete(
  '/delete',
  validateSlideCode(),
  verifyToken(),
  errorQuestionValidate.delErrorQuestionsValidate,
  errorQuestionController.delErrorQuestions
)

/**
 * 错题排序
 */
router.put(
  '/sort',
  verifyToken(),
  errorQuestionValidate.delErrorQuestionsValidate,
  errorQuestionController.sortErrorQuestions
)

module.exports = router
